<%--
  Created by IntelliJ IDEA.
  User: 张振钧
  Date: 2019/1/19
  Time: 14:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Calendar" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form" action="">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>添加收预付款信息</legend>
    </fieldset>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">付款会员</label>
            <div class="layui-input-inline">
                <select name="supplier" lay-verify="required" lay-search="">
                    <option value="北京千锋互联">北京千锋互联</option>
                    <option value="西安传智播客">西安传智播客</option>
                    <option value="尚学堂IT培训">尚学堂IT培训</option>
                    <option value="达内教育">达内教育</option>
                    <option value="尚硅谷精英培训">尚硅谷精英培训</option>
                </select>
            </div>
            <label class="layui-form-label">经手人</label>
            <div class="layui-input-inline">
                <select name="pName" lay-verify="required" lay-search="">
                    <option value="赵六_财务">赵六_财务</option>
                    <option value="王五_人事">王五_人事</option>
                    <option value="张飞_安保">张飞_安保</option>
                    <option value="关羽_后勤">关羽_后勤</option>
                    <option value="刘备_总管">刘备_总管</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">单据编号</label>
            <div class="layui-input-inline">
                <input type="text" name="billNo" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">单据日期</label>
            <div class="layui-input-inline">
                <input type="text" name="billTime" id="date" lay-verify="datetime" placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">账户名称</label>
            <div class="layui-input-inline">
                <select name="projectName" lay-verify="required" lay-search="">
                    <option value="保养汽车">保养汽车</option>
                    <option value="洗车">洗车</option>
                    <option value="全车贴膜_高档">全车贴膜_高档</option>
                    <option value="全车贴膜_普通">全车贴膜_普通</option>
                    <option value="利息收入">利息收入</option>
                    <option value="房租收入">房租收入</option>
                </select>
            </div>
            <label class="layui-form-label">金额</label>
            <div class="layui-input-inline">
                <input type="text" name="eachAmount" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <%--<div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">项目备注</label>
            <div class="layui-input-inline">
                <input type="text" name="username" lay-verify="required" placeholder="暂无备注" autocomplete="off" class="layui-input" style="width: 500px;">
            </div>
        </div>
    </div>--%>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea placeholder="暂无备注" class="layui-textarea" name="remark"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <%--<label class="layui-form-label">收款账户</label>
            <div class="layui-input-inline">
                <select name="account" lay-verify="required" lay-search="">
                    <option value="南通建行">南通建行</option>
                    <option value="流动总账">流动总账</option>
                    <option value="支付宝">支付宝</option>
                    <option value="微信">微信</option>
                    <option value="上海农行">上海农行</option>
                    <option value="长安银行">长安银行</option>
                </select>
            </div>--%>
            <label class="layui-form-label">优惠金额</label>
            <div class="layui-input-inline">
                <input type="text" name="accountId" lay-verify="required|number" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
            <input type="hidden" name="type" value="收预付款" >
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="/layuiadmin/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate','layer','jquery'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate
            ,$=layui.jquery;

        //日期
        laydate.render({
            elem: '#date'
            ,type: 'datetime'
        });


        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });
            window.opener=null;
            window.open('','_self');
            window.close();
            /*异步提交插入*/
            var url='/income/insert';
            $.post(
                url,
                data.field,
                function () {
                    layer.msg("添加成功");
                    /*关闭当前弹窗*/
                    parent.layer.closeAll();
                    parent.location.reload();
                    /*重载表格到第一页*/
                    /*table_cz(1);*/
                }
            );
            return false;
        });

        /*表格重载*/
        function table_cz(index) {
            tableIns.reload({
                where: { //设定异步数据接口的额外参数，任意设
                }
                , page: {
                    curr: index
                }
            });
        }

    });
</script>
</body>
</html>